package com.campus.backend.controller;

import com.campus.backend.bean.user.UserQueryParam;
import com.campus.backend.bean.user.UserStatusBean;
import com.campus.backend.service.UserService;
import com.campus.backend.vo.user.UserVo;
import com.campus.common.bean.common.Pagination;
import com.campus.common.bean.common.Resp;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-05-21
 */

@Api(tags = "用户管理接口")
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @ApiOperation("批量更新用户状态")
    @PutMapping("/batchUpateStatus")
    public Resp<Void> batchUpateStatus(@RequestBody @Validated UserStatusBean userStatusBean) {
        userService.batchUpateStatus(userStatusBean);
        return Resp.success();
    }


    @ApiOperation("分页查询用户列表")
    @GetMapping("/page")
    public Resp<Pagination<UserVo>> getUserDataPage(UserQueryParam queryParam) {
        PageInfo<UserVo> result = userService.getUserDataPage(queryParam);
        return Resp.successPageable(result);

    }
}
